﻿'''
    9*9乘法表的实现
'''

# 1.把乘法表左上角考虑成（1,1）坐标点，每个乘法表达式，等于row*col
# 2.输出是一行一行输出的，每一行输出后需要换行
# 3.每一行的行号，是列从1到行号的循环
# 4.为格式化输出，采用占位

row = 1
col = 1
while row < 10:
    while col < row+1:
        print('{}*{}={:<4}'.format(row,col,row*col),end=' ')
        col = col + 1
    col = 1
    row = row + 1
    print('')

print('='*60)

row = 9
col = 1
while row > 0:
    while col <= row:
        print('{}*{}={:<4}'.format(row,col,row*col),end=' ')
        col = col + 1
    col = 1
    row = row - 1
    print('')

print('='*60)

row = 1
col = 9
while row < 10:
    while col > 0:
        if col > row:
            print(' '*8,end=' ')
        else:
            print('{}*{}={:<4}'.format(col,row,row*col),end=' ')
        col = col -1
    col = 9
    row = row + 1
    print('')

print('='*60)

row = 9
col = 9
while row > 0:
    while col > 0:
        if col > row:
            print(' '*8,end=' ')
        else:
            print('{}*{}={:<4}'.format(col,row,row*col),end=' ')
        col = col - 1
    col = 9
    row = row - 1
    print('')

print('='*60)